package com.niji.littly_donkey_android.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.makeramen.roundedimageview.RoundedImageView;
import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.bean.Fans;
import com.niji.littly_donkey_android.bean.Video;
import com.niji.littly_donkey_android.util.BitMapUtil;
import com.niji.littly_donkey_android.util.CirclePhotoUtil;
import com.niji.littly_donkey_android.util.NetworkGlideImageLoader;
import com.niji.littly_donkey_android.util.UrlUtil;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class MyHomeVideoAdapter extends RecyclerView.Adapter<MyHomeVideoAdapter.ViewHolder> {


    private static final String TAG = "MyHomeVideoAdapter";

    private List<Video> videos;

    private Context context;

    public MyHomeVideoAdapter(Context context,List<Video> videos){
        this.videos = videos;
        this.context = context;
    }


    @NonNull
    @NotNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_my_home_page_video,parent,false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull @NotNull MyHomeVideoAdapter.ViewHolder holder, int position) {
        Video video = videos.get(position);
        holder.my_home_video_id.setText("" + video.getId());
        holder.my_home_video_playNum.setText("" + video.getLikes());
        NetworkGlideImageLoader.getInstance().displayImage((Activity) context,video.getUrl(), holder.my_home_video, 0,0);
        holder.my_home_show_video.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

    }

    @Override
    public int getItemCount() {
        return videos.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {

        ImageView my_home_video;
        TextView my_home_video_id;
        TextView my_home_video_playNum;
        RelativeLayout my_home_show_video;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            my_home_show_video = itemView.findViewById(R.id.my_home_show_video);
            my_home_video = itemView.findViewById(R.id.my_home_video);
            my_home_video_id = itemView.findViewById(R.id.my_home_video_id);
            my_home_video_playNum = itemView.findViewById(R.id.my_home_video_playNum);
        }
    }

}



